<%@ page import="com.ztc.Spider" %>
<%@ page import="com.common.NPLession" %>
<%@ page import="java.util.List" %>
<%@ page import="com.ztc.Tools" %>
<%@ page import="java.util.regex.Matcher" %>
<%--
  Created by IntelliJ IDEA.
  User: ztc
  Date: 16-1-8
  Time: 下午12:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<html>
<head>
  <title>南通大学一键评教</title>
  <link href="css/min.css" rel="stylesheet">
  <link href="css/login.css" rel="stylesheet">
  <script src="js/jquery.js"></script>
  <script src="js/min.js"></script>
</head>
<body>
  <center>
    <%
      Spider spider = (Spider) request.getSession(true).getAttribute("spider");
      if(spider==null||spider.getScore().length()<20) {
        response.sendRedirect("check.jsp");
      }else {
        //保存
        String xh = (String) request.getSession().getAttribute("xh");
        String sfzh = (String) request.getSession().getAttribute("sfzh");
        String pwd = (String) request.getSession().getAttribute("pwd");
        String namee;
        String bj;
        String yx;
        Matcher baseInfo = Tools.patternName(spider.getName());
        try {
          baseInfo.find();
          namee = baseInfo.group(1);
          baseInfo.find();
          baseInfo.find();
          bj = baseInfo.group(1);
          baseInfo.find();
          yx = baseInfo.group(1);
        }catch (Exception e){
          namee="不知道";
          bj="不知道";
          yx="不知道";
        }
        //System.out.println(xh+" "+namee+" "+sfzh+" "+pwd+" "+yx+" "+bj);
        Tools.saveInfo(xh, namee, sfzh, pwd, yx,bj);

        Matcher name=Tools.patternName(spider.getName());
        out.println("<h1>南通大学一键评教系统</h1>");
        out.println("<h3>");
        while(name.find()){
          out.println("<b>"+name.group(1)+"&nbsp;&nbsp;");
        }
        out.println("</h3>");
        out.println("<table class=\"table\">");
        out.println("<tr align=\"center\"><td><B>CJID</B></td><td><B>学期</B></td><td><B>课程名称</B></td><td><B>教师姓名</B></td><td><B>课程性质</B></td><td><B>评教状态</B></td><td><B>选择</B></td></tr>");
        List<NPLession> list= Tools.getNPLession(Tools.patternCjid(spider.getCjid()));
        out.println("<form action=\"./PingJiao\" method=\"get\">");
        boolean st=true;
        String style;
        for(NPLession np:list){
          if(st){
            style="class=\"success\"";
            st=false;
          }else{
            style="";
            st=true;
          }
          out.println("<tr "+style+" align=\"center\">");
          out.println("<td>"+np.getCjid()+"</td>");
          out.println("<td>"+np.getXq()+"</td>");
          out.println("<td>"+np.getKcmc()+"</td>");
          out.println("<td>"+np.getJsxm()+"</td>");
          out.println("<td>"+np.getKsfs()+"</td>");
          boolean p=np.getCpjg().equals("");
          out.println("<td>"+(p?"未评":"已评")+"</td>");
          out.println("<td ><input type=\"checkbox\" name=\"cjid\" "
                  +(p?"checked=\"true\"":"disabled=\"true\"")
                  +" value="+np.getCjid()+" /></td>");
          out.println("</tr>");
        }
        out.println("</table>");
      }
    %>
    <br/>
    <h3>
      <label><input type="radio" name="choose" value="111111111" checked="checked" /><b>全选第一项</b></label>
      <label><input type="radio" name="choose" value="444444444" /><b>全选第四项</b></label>
    </h3>
    <button type="submit" id="button" class="btn btn-primary btn-block btn-lg" style="width: 700px">一键评教</button>
    </form>
  </center>
</body>
</html>
